﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Tauren.File.Infrastructure.Common;
using Tauren.File.Service.FileVersionBLL;

namespace Tauren.File.Core.Controllers
{
    /// <summary>
    /// 文件版本信息
    /// </summary>
    [Route("api/fileversion")]
    [ApiController]
    [ApiVersion("1.0")]
    public class FileVersionController : ControllerBase
    {

        private IFileVersionService service;
        private ITrackFileService trackFileService;

        /// <summary>
        /// 构造函数
        /// </summary>  
        public FileVersionController(IFileVersionService _service, ITrackFileService _trackFileService)
        {
            this.service = _service;
            this.trackFileService = _trackFileService;
        }
        /// <summary>
        /// 获取所有历史的信息
        /// </summary>
        /// <returns></returns>
        [HttpPost, Route("v{version}/hist"), ApiVersion("1.0")]
        public IActionResult RefreshHistory([FromQuery] int fileid)
        {
            return this.service.RefreshHistory(fileid: fileid).ToJsonResult();
        }
        /// <summary>
        /// 获取所有历史的信息
        /// </summary>
        /// <returns></returns>
        [HttpPost, Route("v{version}/sethist"), ApiVersion("1.0")]
        public IActionResult SetHistoryData([FromQuery] int fileid, [FromQuery] int version)
        {
            return this.service.SetHistoryData(fileid: fileid, version: version).ToJsonResult();
        }
        /// <summary>
        /// 获取配置文件
        /// </summary>
        /// <returns></returns>
        [HttpPost, Route("v{version}/config"), ApiVersion("1.0")]
        public IActionResult Config([FromQuery] int editType, [FromQuery] int systemType, [FromQuery] int fileid)
        {
            return this.service.Config(editType: editType, systemType: systemType, fileid: fileid).ToJsonResult();
        }
    }
}
